package com.example.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 描述:
 * 作者：
 * 日期： 2020/5/8 13:28
 **/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new AuthInterceptor())
//                .addPathPatterns("/api/**")
//                .addPathPatterns("/page/end/**")
//                .excludePathPatterns("/page/end/login.html", "/page/end/register.html")
//                .excludePathPatterns("/api/user/login", "/api/user/register")
//                .excludePathPatterns("/api/setmeal","/api/setmeal/setmealMore");
//    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 文件磁盘url 映射
        // 配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
        //此处将  /PlaybackData/  映射为右侧的路径
        registry.addResourceHandler("/image/**").addResourceLocations("file:D:\\mydata\\springboot\\dsyimei/src/main/resources/static/file/");//linux,注意Linux中不要有//
        //若是java:"file:E:\\\\wetemHeadUrlbProject\\FileWebsite\\PlaybackData\\"  (其中\\可以换为/)
        //http://localhost:13389/PlaybackData/434524.txt
        //映射为:/home/javauser/project1/logs/files/flydata/PlaybackData/434524.txt
    }
}
